home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
8bitfiles.net/archives
/
archives.tar
/
archives
/
compuserve-file-archive
/
05 Programming
/
RS232.ARC
/
%c3%a4%c2%c2%d3%a4%cd%cc.A
next >
Wrap
Text File
|
2019-04-13
|
16KB
|
551 lines
;----------------------------------------------------------------------
; ├ñ┬┬╙ñ═╠.A
;----------------------------------------------------------------------
#INCLUDE <├┬┬╙ñ╦ERNAL.EQU>
.DEF ├╥ñ═ODEM, CURSOR, PROMPT, SECURE, QUOTE, CARRAGE
.DEF ═Oñ╔NKEY, ╘ERMINAL, INKEY, ═OñPUTC, ═ODEMñ╙╘
.DEF ═Oñ╧PEN, ═Oñ├LOSE, ═OñPUTS, ╪LATE
.REF C$FUNCTñINIT
;
; ╪LATE(├,ASCII) CHAR ├ TO ASCII OR TO PET
;; ├ñ╔DLE(TMIN,OMIN) MINUTES IN TENS/ONES 0..9(MAX 59 TOTAL)
; ═Oñ╧PEN(CONTROLñ╥,COMMANDñ╥,┬ñ╥ñ╠OW,┬ñ╥ñ╚I)
; CHAR PARAMITERS FILE# IS 5 AFTER OPEN
; ═Oñ├LOSE() CLOSES #5
; ═OñPUTS(STR,ASCII) SEND STRING (0 TERMINATOR)
;
;; ╨ASSñ╔N(STR,MAX,ASCII) GET PASSWORD OR OTHER SECURE DATA FROM REMOTE
; USER ╫/╧ SHOWING DATA TYPED (NO EDITING ALLOWED!)
; ═Oñ╔NKEY(ASCII) RETURNS 1 CHAR ASCII IS TRANS-FLAG
; ╘ERMINAL(ASCII,ECHO) RETURNS STATUS CODE ╞-╦EY ┼╧╞ ETC...
; ECHO IS 1 FOR LOCAL ECHO (USE FOR HOST MODE)
; INKEY() RETURNS 1 KEY OR ╬╔╠╠ (NO KEY)
; ═OñPUTC(C,ASCII) SENDS 1 CHAR
;; ═OñGETS(STRING,═AX,ASCII) RETURNS ┼╧╞,NUMBERñREAD,OR SYSOP ╦EY OR
; TIMEOUT
; CHAR *STRING,═AX; STRING MUST BE DECLARED ELSEWHERE THIS PARAM
; INT ASCII IS THE ADRRESS OF STRING (A POINTER)
;----------------------------------------------------------------------
; CHAR1 IS THE CURSOR TO BE USED ON THE HOST SCREEN
CHAR1 .BYTE 'ñ
;
; CHAR2 IS THE REMOTE SECURITY CHARACTER FOR PASSWORD PROTECTION
CHAR2 .BYTE '#
;
; CHAR3 IS THE SYSTEM PROMPT TO PLACE ON A LINE FOR INPUT
CHAR3 .BYTE '>
;-------------------------------------------------------------------
PROMPT PHA
LDX #$05
JSR C$CHKOUT
LDA CHAR3
JSR C$CHROUT
JSR C$CLRCHN
JSR C$CHROUT ;LOCAL ECHO
PLA
RTS
;
SECURE PHA
LDX #$05
JSR C$CHKOUT
LDA CHAR2
JSR C$CHROUT
JSR C$CLRCHN
JSR C$CHROUT ;LOCAL ECHO
PLA
RTS
;
CURSOR PHA
LDA CHAR1
JSR C$CHROUT
LDA #$9D
JSR C$CHROUT
PLA
RTS
;
QUOTE PHA
PHP
TXA
PHA
LDX #7
LDA #0
JSR C$MEM
LDA #$22
STA ┴ñ╥EG
LDA #$0F
STA ┬ANK
LDA #$C2
STA ╨├ñ╚IGH
LDA #$FF
STA ╨├ñ╠OW
JSR C$JSRñFAR
PLA
TAX
PLP
PLA
RTS
;
CARRAGE PHA
LDA #$20
JSR C$CHROUT
PLA
RTS
;
├╥ñ═ODEM PHA
LDA #$0D
JSR OUTREMOTE
JSR C$CHROUT ;LOCAL ECHO
PLA
RTS
;
; ╧PENñ╨ORT(CONTROL,COMMAND,BAUDñLOW,BAUDñHI)
;
; ╬╧╘┼: BAUD NUST BE GIVEN IN LOW/HI AS 0,0 IF USING STD RATES
; TEST THE OPEN BY C=╧PENñ╨ORT(X,X,X,X)
; C=0 ╧╦ C=$╞╞ BAD OPEN!
═Oñ╧PEN JSR C$FUNCTñINIT
STX C$LOCAL
LDA C$PARAMS,X
STA CONTROL
LDA C$PARAMS+1,X
STA COMMAND
LDA C$PARAMS+2,X ; FOR USER DEFINED BAUD RATE
STA ┬ñ╥ñ╠OW
LDA C$PARAMS+3,X
STA ┬ñ╥ñ╚I
LDX #<CONTROL ; GET ADDRESS OF FILENAME
LDY #>CONTROL ; (TO SET MODEM PARAMS)
LDA #05 ; SET STRING SIZE AS 5
JSR C$SETNAM
LDX #01 ; NAME IS IN BANK1 RAM
JSR C$SETBNK
LDA #05 ; OPEN 5,2,0
LDX #02 ; FOR ╨UNTER COMPATABILITY
LDY #00
JSR C$SETLFS
JSR C$OPEN
BCS ERRORñCD ; TEST FOR ERRORS
LDX C$LOCAL
LDA #00
OUT═ STA C$PARAMS,X
RTS
ERRORñCD LDX C$LOCAL
LDA #$FF
JMP OUT═
;
; ├LOSEñ╨ORT() JUST TAKE THE FILE# AND DO IT
═Oñ├LOSE LDA #05
JMP C$CLOSE ; WILL RETURN VIA THE JSR TO THIS CODE
;
; ├ ENTERY POINT FOR ═ODEMñ╔NKEY(ASCII)
; RETURNS CHAR OR ┼╧╞
; ASCII IS A TRANSLATION FLAG
═Oñ╔NKEY JSR C$FUNCTñINIT
STX C$LOCAL
LDA C$PARAMS,X
STA ASCII
JSR REMOTE
LDA RS232OK
BNE BAD232
LDA INCHAR
LDX C$LOCAL
STA C$PARAMS,X
LDA #00
STA C$PARAMS+1,X
RTS ; GOOD STATUS
;
BAD232 LDX C$LOCAL
LDA #$FF
STA C$PARAMS,X
LDA #$FF
STA C$PARAMS+1,X
RTS
;
REMOTE
LDX #$05
JSR C$CHKIN
JSR C$GETIN
PHA
JSR C$CLRCHN
JSR MODEMSTATUS
PLA
LDY ASCII
BEQ TRUEIN
JMP PETIN
TRUEIN TAY
LDA TRANSIN,Y
PETIN STA INCHAR
RTS
EMPTY LDA #0
JMP PETIN
;
; INKEY() NO WAITS IN THIS
INKEY JSR C$FUNCTñINIT
STX C$LOCAL
JSR POLLKEYS
LDX C$LOCAL
LDA LOCAL
STA C$PARAMS,X
LDA #00
STA C$PARAMS+1,X
RTS
;
POLLKEYS LDA #0
STA LOCAL
JSR C$CLRCHN
JSR C$GETIN
STA LOCAL
RTS
;
; ╘ERMINAL(ASCII,ECHO)
; INT SIZE ^
╘ERMINAL JSR C$FUNCTñINIT
STX C$LOCAL
LDA C$PARAMS,X
STA ASCII ; INITALIZE FOR ├
LDA C$PARAMS+2,X
STA ECHO
TERMLOOP JSR REMOTE
LDA RS232OK
BNE BREAK ; MODEM ERROR!
LDA INCHAR
BEQ OK1
LDX ECHO
BEQ TERMLF
JSR OUTREMOTE
TERMLF CMP #$0A ; LINE FEED
BEQ OK1
CMP #$0D ; CARRAGE RETURN
BNE OK
JSR CARRAGE
OK JSR C$CHROUT
CMP #$22
BNE OK1
JSR QUOTE
OK1 JSR CURSOR
JSR POLLKEYS
LDA LOCAL
BEQ TERMLOOP ; NO LOCAL INPUT LOOP BACK
CMP #$1B ; ESCAPE THEN EXIT WITH VALUE
BEQ FUNCTEXIT
CMP #$81 ; IF (LOCAL >= ╞1)
BCS FUNCT1 ; THEN ....
LOOP JSR OUTREMOTE ; ELSE SEND CHAR TO REMOTE
LDX ECHO
BEQ NOECHO
CMP #$0D ; CARRAGE RETURN
BNE LPX1
JSR CARRAGE
LPX1 JSR C$CHROUT ; ┘ES
NOECHO JMP TERMLOOP ; AND LOOP BACK
FUNCT1 CMP #$8D ; IF( LOCAL <= ╞8)
BCC FUNCTEXIT ; IN RANGE ╞1..╞8
JMP LOOP ; ELSE LOOP BACK FOR OUTPUT
;
FUNCTEXIT LDX C$LOCAL
STA C$PARAMS,X
LDA #00
STA C$PARAMS+1,X
RTS ; RETURN KEY VALUE
;
BREAK LDX C$LOCAL ; ERROR EXIT
LDA #$FF
STA C$PARAMS,X
LDA #$FF
STA C$PARAMS+1,X ; ┼╧╞ (-1)
RTS
;
; ═ODEMñPUTC(CHAR,ASCII)
; INT SIZE ^
═OñPUTC JSR C$FUNCTñINIT
STX C$LOCAL
LDA C$PARAMS+2,X
STA ASCII
LDA C$PARAMS,X
;
OUTREMOTE PHA
LDY ASCII
BEQ TRUEOUT
JMP PETOUT
TRUEOUT TAY
LDA TRANSOUT,Y
PETOUT PHA
LDX #$05
JSR C$CHKOUT
PLA
JSR C$CHROUT
JSR C$CLRCHN
PLA
RTS
;
; ═ODEMñPUTS(STR,ASCII)
═OñPUTS JSR C$FUNCTñINIT
STX C$LOCAL
LDA C$PARAMS,X
STA C$LOCAL+1
LDA C$PARAMS+1,X
STA C$LOCAL+2
LDA C$PARAMS+2
STA ASCII
LDA #$00
TAY
TAX
OUT╠OOP LDA (C$LOCAL+1),Y ; SEND OUT DATA UNTILL ZERO (STRING END)
CMP #0
BEQ DONE╧UT
STY ┘ñ╘EMP
STA ┴ñ╘EMP
JSR OUTREMOTE
LDA ┴ñ╘EMP
CMP #$0D
BNE OUT1
JSR CARRAGE
OUT1 JSR C$CHROUT
CMP #$22
BNE OUT2
JSR QUOTE
OUT2 JSR CURSOR
JSR MODEMSTATUS
LDA RS232OK
BNE OUT┼╥╥ ; ERROR ON NOT-EQUAL ZERO
LDY ┘ñ╘EMP
INY
BNE OUT╠OOP
DONE╧UT LDX C$LOCAL
LDA #0
DONE2 STA C$PARAMS,X ; OK RETURN $00
LDA #0
STA C$PARAMS+1,X
RTS
OUT┼╥╥ LDX C$LOCAL ; ON ERROR ERTURN $╞╞
JMP DONE2
;
;
;
MODEMSTATUS LDA #$00
STA RS232OK
LDX #$0F
LDY #$00
LDA #<RS232EN
STA TARGET1
LDA #>RS232EN
STA TARGET2
JSR ╔╬─╞┼╘
STA RS232ENABLE
LDX #$0F
LDY #$00
LDA #<RS232SREG
STA TARGET1
LDA #>RS232SREG
STA TARGET2
JSR ╔╬─╞┼╘
STA RS232STATUS
LDX #$0F
LDY #$00
LDA #<RS232PORT
STA TARGET1
LDA #>RS232PORT
STA TARGET2
JSR ╔╬─╞┼╘
STA RS232PORTSTAT
AND #%00010000 ; IS THERE A CARRIER?
BNE RS232ERROR ; ╬O! SET FLAG ╒P
LDA RS232STATUS
AND #%10000000 ; IS THERE A BREAK OR FRAMING ERROR?
BNE RS232ERROR ; ┘ES! SET FLAG ╒P
DONE RTS
;
RS232ERROR STA ┴ñ╘EMP
LDA #$FF
STA RS232OK
JMP DONE
;
;
; ═ODEMñ╙╘(&ENABLE,&STATUS,&PORTST) PASS ADDRESSES TO INT'S
; THEN READ THE RESULTS IN THE NAMED INT VARIABLES
═ODEMñ╙╘ JSR C$FUNCTñINIT
STX C$LOCAL
LDY #00
LDA C$PARAMS,X ; ╞OR EACH ONE PICK UP AN ADDRESS
STA C$LOCAL+1 ; MAKE IT INTO A ┌╨-POINTER
LDA C$PARAMS+1,X ; THEN LOAD THE VALUE FROM THE
STA C$LOCAL+2 ; BANK1 PSEUDO-REGISTER
LDA RS232ENABLE ; AND SEND IT TO THE ADDRESS POINTED TO
STA (C$LOCAL+1),Y ; DO THIS THREE TIMES AND DONE.
LDA C$PARAMS+3,X ; ╘HIS GIVES THE STATUS FROM THE LAST
STA C$LOCAL+1 ; RS232 ╔/╧ THAT WAS PERFOMED THRU
LDA C$PARAMS+4,X ; THE MODEM ╔/╧ CODE IN THIS SET OF
STA C$LOCAL+2 ; ├ FUNCTIONS.
LDA RS232STATUS
STA (C$LOCAL+1),Y
LDA C$PARAMS+5,X
STA C$LOCAL+1
LDA C$PARAMS+6,X
STA C$LOCAL+2
LDA RS232PORTSTAT
STA (C$LOCAL+1),Y
RTS
;---------------------------------------------------------------------
; LDAñFAR/STAñFAR CODE FOR CLOCK/MODEM FUNCTIONS
; A DESTROYED A = VALUE FOUND BY INDFET
; Y IS AN OFFSET FROM TARGET
; X IS BANK# (0..15)
╔╬─╞┼╘
TXA
PHA
LDX #$07 ; ══╒ ╨AGE ┌ERO ╨TR ╥EGISTER -----FIX
LDA #$00 ; ══╒ ╨TR ╓ALUE
JSR C$MEM ; SWAP EM
PLA
TAX
LDA TARGET1 ; TARGET ADDRESS LOWBYTE
STA C$PARAMSIZE+1
LDA TARGET2 ; HIBYTE
STA C$PARAMSIZE+2
LDA #$0F ; SET BANK15
STA ┬ANK
LDA #$FF
STA ╨├ñ╚IGH
LDA #$74
STA ╨├ñ╠OW ; CALL $╞╞74 - ╠─┴ñ╞┴╥(C$PARAMSIZE),Y
PHP
PLA
STA ╙ñ╥EG
LDA #$FC
STA ┴ñ╥EG
STX ╪ñ╥EG
STY ┘ñ╥EG ; SET ┘ TO ┌┼╥╧ SEE ABOVE ^
JSR C$JSRñFAR ; CALL ╩╙╥ñ╞┴╥ ╔╬─ñ╞┼╘ ( ^ )
LDA ┴ñ╥EG ; GET RETURNED VALUE
PHA ; ╨╒╙╚ ON STACK
LDX #$07 ; ╥┼╙╘╧╥┼ ┌ERO ╨AGE -------FIX
LDA #$13 ; FOR ╨OWER ├
JSR C$MEM ; SWAP
PLA ; ╨╧╨ VALUE
RTS ; RETURN
;
╔╬─╙╘┴ STA STOREVAL
TXA
PHA
LDX #$07 ;-----FIX
LDA #$00
JSR C$MEM
PLA
TAX
LDA TARGET1
STA C$PARAMSIZE+1
LDA TARGET2
STA C$PARAMSIZE+2
LDA #$FC
STA ╙╘┴╓┼├
LDA #$0F
STA ┬ANK
LDA #$FF
STA ╨├ñ╚IGH
LDA #$77
STA ╨├ñ╠OW
PHP
PLA
STA ╙ñ╥EG
LDA STOREVAL
STA ┴ñ╥EG
STX ╪ñ╥EG
STY ┘ñ╥EG
JSR C$JSRñFAR
LDX #$07 ;---------FIX
LDA #$13
JMP C$MEM
;
╪LATE JSR C$FUNCTñINIT
LDY C$PARAMS+1,X ;GET ASCII FLAG
LDA C$PARAMS,X ;GET CHARACTER TO CONVERT
CPY #0
BNE TOñPET
TAY ; USE ASCII VALUE AS INDEX
LDA TRANSOUT,Y ; PICK-UP NEW VALUE
JMP TDONE
TOñPET TAY
LDA TRANSIN,Y
TDONE STA C$PARAMS,X ; RETURN NEW CHARACTER
RTS
;
;
.BYTE "CODE-END"
;
;----------------------------------------------------------------------------
; DATA AND TRANSLATION TABLES FOR ├/═╠ FUNCTIONS
;ññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññ
RS232ENABLE .BYTE 0
RS232STATUS .BYTE 0
RS232PORTSTAT .BYTE 0
RS232OK .BYTE 0
;
ECHO .BYTE 0
IDLEON .BYTE 0
LOCAL .BYTE 0
INCHAR .BYTE 0
BUFPTR .BYTE 0
CURLEN .BYTE 0
MAXLEN .BYTE 0
ASCII .BYTE 0
CONTROL .BYTE 0
COMMAND .BYTE 0
┬ñ╥ñ╠OW .BYTE 0
┬ñ╥ñ╚I .BYTE 0
.BYTE 0 ; PAD FOR ═ODEM ╞ILE NAME
TBANK .BYTE 0
TARGET1 .BYTE 0
TARGET2 .BYTE 0
OFFSET .BYTE 0
STOREVAL .BYTE 0
┴ñ╘EMP .BYTE 0
┘ñ╘EMP .BYTE 0
╪ñ╘EMP .BYTE 0
.BYTE "TABLE-START"
;----------------------------------------------------------------------------
; ┴╙├╔╔/╨┼╘┴╙├╔╔ ╘╥┴╬╙╠┴╘╔╧╬ ╘┴┬╠┼╙
;ññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññññ
TRANSOUT
.BYTE $00,$01,$02,$03,$04,$05,$06,$07,$08,$09,$0A,$0B,$0C,$0D,$0E,$0F
.BYTE $10,$11,$12,$13,$08,$15,$16,$17,$18,$19,$1A,$1B,$1C,$1D,$1E,$1F
.BYTE $20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$2A,$2B,$2C,$2D,$2E,$2F
.BYTE $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3A,$3B,$3C,$3D,$3E,$3F
.BYTE $40,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6A,$6B,$6C,$6D,$6E,$6F
.BYTE $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7A,$5B,$5C,$5D,$5E,$5F
.BYTE $60,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6A,$6B,$6C,$6D,$6E,$6F
.BYTE $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7A,$5B,$5C,$5D,$7E,$7F
.BYTE $80,$81,$82,$83,$84,$85,$86,$87,$88,$89,$8A,$8B,$8C,$8D,$8E,$8F
.BYTE $90,$91,$92,$93,$94,$95,$96,$97,$98,$99,$9A,$9B,$9C,$9D,$9E,$9F
.BYTE $A0,$A1,$A2,$A3,$A4,$A5,$A6,$A7,$A8,$A9,$AA,$AB,$AC,$AD,$AE,$AF
.BYTE $B0,$B1,$B2,$B3,$B4,$B5,$B6,$B7,$B8,$B9,$BA,$BB,$BC,$BD,$BE,$BF
.BYTE $C0,$41,$42,$43,$44,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E,$4F
.BYTE $50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$5A,$5B,$5C,$5D,$DE,$DF
.BYTE $E0,$E1,$E2,$E3,$E4,$E5,$E6,$E7,$E8,$E9,$EA,$EB,$EC,$ED,$EE,$EF
.BYTE $F0,$F1,$F2,$F3,$F4,$F5,$F6,$F7,$F8,$F9,$FA,$FB,$FC,$FD,$FE,$FF
;
TRANSIN
.BYTE $00,$01,$02,$03,$04,$05,$06,$07,$14,$09,$0A,$0B,$0C,$0D,$0E,$0F
.BYTE $10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$1A,$1B,$1C,$1D,$1E,$1F
.BYTE $20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$2A,$2B,$2C,$2D,$2E,$2F
.BYTE $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3A,$3B,$3C,$3D,$3E,$3F
.BYTE $40,$C1,$C2,$C3,$C4,$C5,$C6,$C7,$C8,$C9,$CA,$CB,$CC,$CD,$CE,$CF
.BYTE $D0,$D1,$D2,$D3,$D4,$D5,$D6,$D7,$D8,$D9,$DA,$5B,$5C,$5D,$5E,$5F
.BYTE $60,$41,$42,$43,$44,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E,$4F
.BYTE $50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$5A,$5B,$5C,$5D,$7E,$14
.BYTE $00,$01,$02,$03,$04,$05,$06,$07,$14,$09,$0A,$0B,$0C,$0D,$0E,$0F
.BYTE $10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$1A,$1B,$1C,$1D,$1E,$1F
.BYTE $20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$2A,$2B,$2C,$2D,$2E,$2F
.BYTE $30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$3A,$3B,$3C,$3D,$3E,$3F
.BYTE $40,$61,$62,$63,$64,$65,$66,$67,$68,$69,$6A,$6B,$6C,$6D,$6E,$6F
.BYTE $70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$7A,$5B,$5C,$5D,$5E,$7F
.BYTE $80,$41,$42,$43,$44,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E,$4F
.BYTE $50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$5A,$FB,$FC,$FD,$FE,$14
;
;
;